/*
 * Copyright 2013 Sigurd Randoll <srandoll@digiway.de>.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package de.digiway.rapidbreeze.server.model.config;

import java.util.Map;

/**
 * An instance of this interface controlls the access to an unspecified amount
 * of configuration options. Configuration options can be written and read.
 *
 * @author Sigurd Randoll <srandoll@digiway.de>
 */
public interface ConfigurationRepository {

    /**
     * Reads a configuration value of the given key
     *
     * @param key
     * @return value or null if not existing
     */
    public <T> T getValue(String key);

    /**
     * Sets the given configuration value for the given key.
     *
     * @param key
     * @param value
     */
    public void setValue(String key, Object obj);

    /**
     * Returns a {@linkplain Map} of all configured configuration entries.
     *
     * @return
     */
    public Map<String, Object> getAllConfigurations();

    /**
     * Clears all configuration options.
     */
    public void clearAll();

    /**
     * Adds a listener which will be informed about configuration changes.
     *
     * @param listener
     */
    public void addListener(ConfigurationChangeListener listener);

    /**
     * Removes a previously registered listener.
     *
     * @param listener
     */
    public void removeListener(ConfigurationChangeListener listener);
}
